-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Benchmarks #113
base: master
Are you sure you want to change the base?
Benchmarks #113
Conversation
… a fixed number of limbs
… add tests for gcd
Add random functions from another PR to benchmark with random bigint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good to me! I'm not really fond of benchy
, since it only displays numbers in milliseconds, but I don't know of a better alternative. The benchmarking code has a lot of duplication, that could be easily reduced by extracting the benchmarking code into a proc/template. I think we should also bench BigInt
s with less than 100 limbs, e.g. 10, 2, or 1, since I think those will be more common for casual uses of BigInt
s.
# block: | ||
# randomize() | ||
# let a: BigInt = initRandomBigInt(33) | ||
# echo a | ||
|
||
static: main() | ||
|
||
#static: main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to comment out the static tests and randomized versions. In the future, I will need to remove these comments and let this file in its initial state.
in the past I did some benchmarking (addition and multiplication, inspired by a Js benchmarking suite) during a PR (then removed the code). They were done using library criterion and published results in a generated md file. Maybe it can turn out useful for this PR: #35 (comment) |
I benchmarked multiplication, division, random generation of bigints. Without flags, the operations are slow, with flags, the timings looks correct to me.
The code source quality of benchBigints.nim can be improved with templates to do less copy-paste in the future.
I have also changed some of the examples to import them (by exporting some procedures and using whenIsmainmodule) so that I can benchmark them.
I added some corresponding nimble tasks.
I use
-d:lto -d:danger --opt:speed
flags for benchmarks.I consider using benchy for benchmarks is ok, it does not make it a dependency of the full library, it is only required for benchmarks.
This PR might be really useful for easy comparison of our changes to the library.